home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-05-22 | 7.1 KB | 228 lines | [TEXT/CWIE] |
- // =================================================================================
- // CPict2AsciiApp.cp 1997 BB's Team inc. All rights reserved
- // =================================================================================
- #include "PLConstants.h"
- #include "CPreferences.h"
- #include "CDocument.h"
- #include "CPict2AsciiApp.h"
-
- #include "CDynamicEditField.h"
- #include "CMemoryIndicator.h"
- #include "LDynamicPopupMenu.h"
- #include "CDynamicText.h"
- #include "CGreyCaption.h"
- #include "CGWorldPane.h"
-
- // StandardGetFilePreview
- #include <ImageCompression.h>
-
- #include <LGrowZone.h>
- #include <LMenu.h>
- #include <LMenuBar.h>
- #include <LStdControl.h>
- #include <LString.h>
- #include <UDesktop.h>
- #include <UDrawingState.h>
- #include <UMemoryMgr.h>
- #include <LDialogBox.h>
- #include <UReanimator.h>
- #include <URegistrar.h>
- #include <LEditField.h>
- #include <LPrintOut.h>
- #include <LRadioGroup.h>
- #include <LActiveScroller.h>
- #include <LGroupBox.h>
-
- #include <PP_Messages.h>
-
- #ifdef PL_DEBUG
- #include <LSIOUXAttachment.h>
- #endif
-
- // =================================================================================
- // • Main Program
- // =================================================================================
- void
- main( void )
- {
- // Initialize the heap. Parameter is number
- // of master handle blocks to allocate.
- InitializeHeap( 4 );
-
- // Initialize the MacOS toolbox.
- UQDGlobals::InitializeToolbox( &qd );
-
- // Setup the throw and signal actions.
- #ifdef PL_DEBUG
- SetDebugThrow_( debugAction_Alert );
- SetDebugSignal_( debugAction_Alert );
- #endif
-
- // Install a GrowZone function to catch low memory situations.
- // Parameter is the size of the memory reserve in bytes.
- new LGrowZone( 30000 );
-
- // Create the application object and run it.
- CPict2AsciiApp theApp;
- theApp.Run();
- }
-
-
- // ---------------------------------------------------------------------------------
- // • CPict2AsciiApp
- // ---------------------------------------------------------------------------------
- CPict2AsciiApp::CPict2AsciiApp()
- {
- // Register PowerPlant class creator functions.
- URegistrar::RegisterClass(LCaption::class_ID, (ClassCreatorFunc) LCaption::CreateCaptionStream);
- URegistrar::RegisterClass(LDialogBox::class_ID, (ClassCreatorFunc) LDialogBox::CreateDialogBoxStream);
- URegistrar::RegisterClass(LEditField::class_ID, (ClassCreatorFunc) LEditField::CreateEditFieldStream);
- URegistrar::RegisterClass(LPane::class_ID, (ClassCreatorFunc) LPane::CreatePaneStream);
- URegistrar::RegisterClass(LPlaceHolder::class_ID, (ClassCreatorFunc) LPlaceHolder::CreatePlaceHolderStream);
- URegistrar::RegisterClass(LPrintout::class_ID, (ClassCreatorFunc) LPrintout::CreatePrintoutStream);
- URegistrar::RegisterClass(LStdButton::class_ID, (ClassCreatorFunc) LStdButton::CreateStdButtonStream);
- URegistrar::RegisterClass(LStdCheckBox::class_ID, (ClassCreatorFunc) LStdCheckBox::CreateStdCheckBoxStream);
- URegistrar::RegisterClass(LStdRadioButton::class_ID,(ClassCreatorFunc) LStdRadioButton::CreateStdRadioButtonStream);
- URegistrar::RegisterClass(LStdPopupMenu::class_ID, (ClassCreatorFunc) LStdPopupMenu::CreateStdPopupMenuStream);
- URegistrar::RegisterClass(LWindow::class_ID, (ClassCreatorFunc) LWindow::CreateWindowStream);
-
- URegistrar::RegisterClass(LRadioGroup::class_ID, (ClassCreatorFunc) LRadioGroup::CreateRadioGroupStream);
- URegistrar::RegisterClass(LActiveScroller::class_ID,(ClassCreatorFunc) LActiveScroller::CreateActiveScrollerStream);
- URegistrar::RegisterClass(LGroupBox::class_ID, (ClassCreatorFunc) LGroupBox::CreateGroupBoxStream);
-
- // Register custom classes.
- URegistrar::RegisterClass( CDynamicText::class_ID, (ClassCreatorFunc) CDynamicText::CreateDynamicTextStream );
- URegistrar::RegisterClass( CGreyCaption::class_ID, (ClassCreatorFunc) CGreyCaption::CreateGreyCaptionStream );
- URegistrar::RegisterClass( CGWorldPane::class_ID, (ClassCreatorFunc) CGWorldPane::CreateGWorldPaneStream );
- URegistrar::RegisterClass(LDynamicPopupMenu::class_ID, (ClassCreatorFunc) LDynamicPopupMenu::CreateLDynamicPopupMenuStream );
- URegistrar::RegisterClass( CMemoryIndicator::class_ID, (ClassCreatorFunc) CMemoryIndicator::CreateMemoryIndicatorStream );
- URegistrar::RegisterClass(CDynamicEditField::class_ID, (ClassCreatorFunc) CDynamicEditField::CreateDynamicEditFieldStream );
-
- #ifdef PL_DEBUG
- AddAttachment(new LSIOUXAttachment); // *** Use SIOUX Attachment
- #endif
- mPreferences.FinishCreate();
- }
-
-
- // ---------------------------------------------------------------------------------
- // • ~CPict2AsciiApp
- // ---------------------------------------------------------------------------------
- CPict2AsciiApp::~CPict2AsciiApp()
- {
- }
-
-
- // ---------------------------------------------------------------------------------
- // • StartUp
- // ---------------------------------------------------------------------------------
- void
- CPict2AsciiApp::StartUp()
- {
- // ObeyCommand (cmd_Open, nil );
- }
-
-
- // ---------------------------------------------------------------------------------
- // • FindCommandStatus
- // ---------------------------------------------------------------------------------
- void
- CPict2AsciiApp::FindCommandStatus(
- CommandT inCommand,
- Boolean &outEnabled,
- Boolean &outUsesMark,
- Char16 &outMark,
- Str255 outName )
- {
- switch ( inCommand ) {
-
- case cmd_New:
- outEnabled = false;
- break;
-
- case cmd_Preferences:
- outEnabled = true;
- break;
-
- default:
- {
- // Call inherited.
- LDocApplication::FindCommandStatus( inCommand,
- outEnabled, outUsesMark, outMark, outName );
- }
- break;
-
- }
- }
-
-
-
- // ---------------------------------------------------------------------------
- // • ObeyCommand
- // ---------------------------------------------------------------------------
- // Respond to commands
-
- Boolean
- CPict2AsciiApp::ObeyCommand(
- CommandT inCommand,
- void *ioParam)
- {
- Boolean cmdHandled = true;
-
- switch (inCommand) {
-
- case cmd_Preferences:
- mPreferences.DoDialog (mPreferences.GetAllowed());
-
- // No active menus when back from dialog ?
- // In fact, no target at all !
- SwitchTarget(this);
- break;
-
- case cmd_PageSetup:
- SetupPage();
- break;
-
- default:
- cmdHandled = LDocApplication::ObeyCommand(inCommand, ioParam);
- break;
- }
-
- return cmdHandled;
- }
-
-
- // ---------------------------------------------------------------------------------
- // • OpenDocument (Called in response to the ODOC event)
- // ---------------------------------------------------------------------------------
- void
- CPict2AsciiApp::OpenDocument(
- FSSpec *inMacFSSpec )
- {
- new CDocument (this, inMacFSSpec, &mPreferences);
- }
-
-
- // ---------------------------------------------------------------------------------
- // • ChooseDocument (called by the "open" menu item)
- // ---------------------------------------------------------------------------------
- void
- CPict2AsciiApp::ChooseDocument()
- {
- // Deactivate the desktop.
- UDesktop::Deactivate();
-
- // Browse for a document.
- SFTypeList theList = { 'PICT' };
- StandardFileReply theReply;
- ::StandardGetFilePreview (nil, 1, theList, &theReply);
-
- // Reactivate the desktop.
- UDesktop::Activate();
-
- // Send an apple event to open the file.
- if (theReply.sfGood)
- SendAEOpenDoc (theReply.sfFile);
-
- }
-